package com.roast.pages;

import java.util.List;
import com.roast.domain.Address;
import com.roast.domain.Comment;
import org.apache.tapestry5.annotations.Persist;
import org.apache.tapestry5.annotations.Property;

public class PublicComments {

    @Property
    String systemMessage = "     ";

    @Persist
    Address address;

    @Property
    Comment comment;

    public void setAddress(Address address) {
        this.address = address;
    }

    public Address getAddress() {
        return address;
    }

    public List<Comment> getCommentList() {
        List<Comment> commentList = address.getCommentList();
        if (!commentList.isEmpty()) {
            return commentList;
        }
        return null;
    }

    public boolean isNoCommentsTest() {
        return getCommentList() == null;
    }

    void onActivate(String systemMessage) {
        this.systemMessage = systemMessage;
    }

    String onPassivate() {
        return systemMessage;
    }
}
